﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace weba
{
    public partial class usersvc : System.Web.UI.Page
    {
        sjklqDataContext sj = new sjklqDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                loadsj();
            }
        }

        private void loadsj()
        {
           // throw new NotImplementedException();
            var tf= sj.T_UserInfo.ToList();
            C1GridView1.DataSource = tf;
            C1GridView1.DataBind();
        }

        protected void PagerUserService_PageChanged(object sender, EventArgs e)
        {
            var tf = sj.T_UserInfo.Where(h =>( h.T_Person.ToLower().Contains(txtSearchKey.Value.Trim().ToString().ToLower())) && (DDlState.SelectedIndex == 0 | h.T_UserState.ToString() == DDlState.SelectedValue.ToString()) && (DDlClass.SelectedIndex == 0 | h.T_UserType.ToString() == DDlClass.SelectedValue.ToString()) && (DDLLeave.SelectedIndex ==0 | h.T_UserLeave.ToString() == DDLLeave.SelectedItem.Text.ToString()) && (DDLProvince.SelectedIndex == 0 | h.T_Province.ToString() == DDLProvince.SelectedItem.Text.ToString())).ToList();
            C1GridView1.DataSource = tf;
            C1GridView1.DataBind();
        }

        protected void BtnUpdate_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < C1GridView1.Rows.Count;i++ )
            {
           CheckBox ck1=    C1GridView1.Rows[i].FindControl("CheckBox1") as CheckBox;
                if (ck1.Checked==true)
                {
              T_UserInfo ua=      sj.T_UserInfo.Single(h => h.T_UserID.ToString() == ck1.Text.ToString());
                    if (DDlService.SelectedIndex!=-1)
                    {
                    
              ua.T_NowService = DDlService.SelectedItem.Text.ToString();
                    }
                }
            }
            sj.SubmitChanges();
            C1GridView1.DataSource = null;
            var tf = sj.T_UserInfo.ToList();
            C1GridView1.DataSource = tf;
            C1GridView1.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("addkehu.aspx");
        }
    }
}